package pkg

import (
	"github.com/silenceper/wechat/v2"
	"github.com/silenceper/wechat/v2/cache"
	"github.com/silenceper/wechat/v2/officialaccount"
	"github.com/silenceper/wechat/v2/officialaccount/config"
)

type MyWechat struct {
	Wechat          *wechat.Wechat
	Cache           *cache.Memory
	OfficialAccount *officialaccount.OfficialAccount
}

func NewMyWechat(appid string, appSecret string) *MyWechat {
	we := wechat.NewWechat()
	myCache := cache.NewMemory()
	we.SetCache(myCache)
	official := we.GetOfficialAccount(&config.Config{
		AppID:     appid,
		AppSecret: appSecret,
		Cache:     myCache,
	})
	return &MyWechat{
		Wechat:          we,
		Cache:           myCache,
		OfficialAccount: official,
	}
}
